<?php

namespace app\business\controller;

use think\Controller;
use Util\SysDb;
use think\Db;
class Newlist extends Controller
{
    public function newlist()
    {
        $type = trim(input('param.type'));
        $page = trim(input('param.pageNo'));
        $limit= trim(input('param.pageSize'));
        $tol = (intval($page) - 1) * $limit;
        $list =DB::name("sys_article")->order("create_time desc")->where('type', $type)->limit($tol, $limit)->select();
        $this->db = new SysDb();
        $count = $this->db->table('sys_article')->where(['type' => $type]) ->count();
        $data=array();
        array_push($data,$list);
        array_push($data,$count);
        exit(json_encode(['code' => 1, 'message' => 'succ', "result" =>$data]));
    }
    public function newdetail(){
        $id = trim(input('param.id'));
        $this->db = new SysDb();
        $list = $this->db->table('sys_article')->where(['id' => $id]) ->item();
        exit(json_encode(['code' => 1, 'message' => 'succ', "result" =>$list]));

    }
}
